<template>
  <div id="deleteSome">
    <div class="title">删除数据</div>
    <div class="allData">
      <div class="rowHead">
        <div class="id">ID</div>
        <div class="userName">用户名</div>
        <div class="userMsg">用户信息</div>
        <div class="userConcat">联系方式</div>
        <div class="delete">操作</div>
      </div>
      <div class="row" v-for="(item, index) in data" :key="index">
        <div class="id">{{ item.id }}</div>
        <div class="userName">{{ item.userName }}</div>
        <div class="userMsg">{{ item.userMsg }}</div>
        <div class="userConcat">{{ item.userConcat }}</div>
        <div class="delete" @click="deleteOne(item)">删除</div>
      </div>
    </div>
  </div>
</template>
<script>
import api from "@js/api.js";
export default {
  name: "deleteSome",
  data() {
    return {
      data: [],
    };
  },
  mounted() {
    this.getData();
  },
  methods: {
    getData() {
      api.myGet("/api/queryAll", {}).then((res) => {
        this.data = res.data.data;
      });
    },
    deleteOne(item) {
      api.myGet("/api/deleteSome", { id: item.id }).then((res) => {
        console.log("删除一条返回的数据", res);
        this.getData();
      });
    },
  },
};
</script>
<style lang="less" scoped>
#deleteSome {
  user-select: none;
  .title {
    line-height: 50px;
    padding-left: 20px;
  }
  .allData {
    background: #eee;
    .rowHead {
      overflow: hidden;
      line-height: 50px;
      text-align: center;
      div {
        float: left;
        width: 150px;
      }
    }
    .row {
      overflow: hidden;
      line-height: 50px;
      text-align: center;
      div {
        float: left;
        width: 150px;
      }
    }
  }
}
</style>